package com.zach.common.action;

import java.lang.reflect.InvocationTargetException;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts2.interceptor.ServletRequestAware;
/**
 * 在需求动态获取request参数的情况下的基类,
 * 提供对参数的动态访问
 * @author John
 *
 */
public abstract class BaseWildAction extends BaseAction implements ServletRequestAware {
	private static final long serialVersionUID = -3268796329004980788L;
	protected HttpServletRequest request;
	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}
	/**
	 * 用request中的参数来填充destObj中的变量，向对象destObj赋值
	 * @param destObj
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 */
	public void fillObjByRequestParams(Object destObj) throws IllegalAccessException, InvocationTargetException{
		BeanUtils.populate(destObj,request.getParameterMap());
	}
}
